<template>
  <div class="hearing-details">
    <crumb />
    <div class="container">
      <div class="box-left">
        <div class="task-name">任务名称：{{finishedData.oralName}}</div>
        <div class="task-speak">
          <div class="sub-head">任务要求:</div>
          {{finishedData.oralRemark}}
        </div>
        <div class="task-num">答题题量：{{finishedData.subjectNum}}题</div>
      </div>
      <div class="box-right">
        <!-- 训练报告 -->
        <div class="table">
          <div class="table-head">学生课程实践技能作答表</div>
          <div class="table-content">
            <ul>
              <li v-for="(item, index) in finishedData.finishedList" :key="index" @click='$router.push({ name: "skillfollowhistory" })'>
                <!-- <div class="rank">{{item.rank}}</div>-->
                <div class="rank">{{index+1}}</div>
                <div class="avater">
                  <img :src="item.headImgUrl" alt="" v-if="item.headImgUrl"/>
                  <img src="@/assets/images/home_tx@2x.png" alt="" v-else/>
                </div>
                <div class="cont">
                  <div class="top">{{item.stuName}}</div>
                  <div class="bottom">
                   <span><i class="el-icon-time"></i>{{item.finishedTime}}</span>
                   <span><i class="el-icon-s-flag"></i>{{item.score}}</span>
                   <span><i class="el-icon-timer"></i>{{item.duration}}</span>
                    </div>
                </div>
                <div class="zan" @click.stop="speechLike(item.stuBatchId, index, item.isLike)">
                  <div>
                    <i class='el-icon-thumb'></i>
                  </div>
                   <div style="text-align:center;padding-top:5px;color:rgba(0,0,0,.7)">
                     {{item.likeNum}}
                  </div>
                </div>
              </li>
            </ul>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { speechFinishedList, speechLike } from '@/api/student/training/speech'
export default {
  name: 'SkillFollowSuccess',
  data () {
    return {
      finishedData: ''
    }
  },
  mounted () {
    this.speechFinishedList()
  },
  methods: {
    async speechFinishedList () {
      let res = await speechFinishedList(
        {
          lessonOralCatalogId: this.$route.query.lessonOralCatalogId,
          resourceOralId: this.$route.query.resourceOralId
        }
      )
      if (res.code === '200') {
        this.finishedData = res.data
        // console.log('==@', res)
      } else {
        this.$message.error(res.message)
      }
    },
    async speechLike (stuBatchId, index, isLike) {
      let res = await speechLike(
        {
          stuBatchId: stuBatchId,
          likeType: !isLike ? '1' : '0'
        }
      )
      if (res.code === '200') {
        let num = Number(this.finishedData.finishedList[index].likeNum)
        if (!isLike) {
          this.finishedData.finishedList[index].likeNum = num += 1
          this.finishedData.finishedList[index].isLike = true
        } else {
          this.finishedData.finishedList[index].likeNum = num -= 1
          this.finishedData.finishedList[index].isLike = false
        }
        // console.log('==@', res)
      } else {
        this.$message.error(res.message)
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.hearing-details {
  .container {
    display: flex;
    justify-content: space-between;
    .box-left {
      width: 590px;
      min-height: 500px;
      background: #fff;
      padding: 20px;
      .task-name {
        font-size: 16px;
        font-weight: bold;
      }
      .task-speak {
        background: #f5f5f5;
        margin-top: 20px;
        padding: 10px;
        border-radius: 10px 10px 0 0;
        font-size: 14px;
        line-height: 1.5;
        .sub-head {
          color: #009cf6;
          font-weight: bold;
          margin-bottom: 5px;
        }
      }
      .task-num {
        background: #f5f5f5;
        color: #ff905a;
        border-radius: 0 0 10px 10px;
        padding: 0 10px 20px 10px;
        font-size: 14px;
      }
    }
    .box-right {
      width: 590px;
      background: #fff;
      padding: 30px 0;
      .table {
        width: 500px;
        border-radius: 10px;
        border: 1px solid #efefef;
        margin: 0 auto;
        overflow: hidden;
        box-sizing: content-box;
        .table-head {
          background: #f5f5f5;
          line-height: 50px;
          position: relative;
          padding: 0 20px;
          font-size: 14px;
          i {
            position: absolute;
            top: 15px;
            right: 20px;
            font-size: 20px;
            cursor: pointer;
          }
        }
        .table-content {
          background: #fff;
          ul {
            padding: 10px 20px;
            li {
              display: flex;
              align-items: center;
              font-size: 14px;
              position: relative;
              padding: 10px 0;
              &:nth-child(1) .rank,&:nth-child(2) .rank,&:nth-child(3) .rank{
                  border: 1px solid rgba(0,0,0,.5);
                  border-radius: 15px;
              }
              .rank {
                font-size: 18px;
                margin-right: 15px;
                width: 30px;
                height: 30px;
                line-height: 30px;
                text-align: center;
                color:rgba(0,0,0,.5)
              }
              .avater {
                margin: 0 10px;
                img {
                  width: 40px;
                  height: 40px;
                  border-radius: 50%;
                }
              }
              .cont {
                .bottom {
                  font-size: 12px;
                  margin-top: 10px;
                  span{padding-right:10px; color:rgba(0,0,0,.7)}
                }
              }
              .zan {
                position: absolute;
                right: 0;
                cursor: pointer;
              }
            }
          }
        }
      }
    }
  }
}
</style>
